home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / zmdm / util.c < prev    next >
C/C++ Source or Header  |  1993-06-26  |  5KB  |  194 lines

  1. /*
  2.  *     Utilities Module
  3.  *
  4.  *        Jwahar Bammi
  5.  *            usenet: cwruecmp!bammi@decvax.UUCP
  6.  *            csnet:  bammi@cwru.edu
  7.  *            arpa:   bammi@cwru.edu
  8.  *            CompuServe: 71515,155
  9.  */
  10.  
  11.  
  12. #include "zmdm.h"
  13.  
  14. #ifndef Vsync             /* Atari forgot these in osbind.h */
  15. #define Vsync()    xbios(37)
  16. #endif
  17.  
  18. #define goto(r,c)    EscSeq('Y');Bconout(2, r+040);Bconout(2, c+040)
  19.  
  20.      /* External Variables */
  21. extern int  *aline_addr; /* Ptr to base of Aline variables */
  22. extern long *ms_ptr;    /* pointer to my screen memory aligned to a 256
  23.                byte boundary */
  24.  
  25.      /* Globals */
  26. static char *hs_ptr;   /* pointer to his screen memory */
  27. static int  x_saved, y_saved;    /* Saved cursor position */
  28.  
  29. /*
  30.  * my_screen() - Start using my screen memory
  31.  * for all output.
  32.  *
  33.  */
  34. void my_screen()
  35. {
  36.     /* The cursor position has been saved prior to calling this routine */
  37.     x_saved = aline_addr[-14];
  38.     y_saved = aline_addr[-13];
  39.  
  40.     /* save his screen memory pointer */
  41.     hs_ptr = (char *)Logbase();
  42.     
  43.     /* switch to my display memory */
  44.     Setscreen(ms_ptr, ms_ptr, -1);
  45. }
  46.  
  47.  
  48. void his_screen()
  49. {
  50.     /* switch to his Screen memory, wait for a Vblank, so
  51.      * that the Logical Loc == Physical Loc, then pop saved
  52.      * cursor */
  53.     Setscreen(hs_ptr, hs_ptr, -1);
  54.     Vsync();
  55.     Vsync();    /* starts happening at the last one */
  56.     goto(y_saved, x_saved);
  57.     
  58. }
  59.  
  60. /*
  61.  * hit_key() - wait for the user to hit a key
  62.  * 
  63.  */
  64. void hit_key()
  65. {
  66.     Bconws("\r\n");
  67.     EscSeq('p');
  68.     Bconws("Hit Any Key To Continue .....");
  69.     EscSeq('q');
  70.     Bconin(2);
  71.     Bconws("\r\n");
  72. }
  73.  
  74.  
  75. /*
  76.  * find the size of a file given its name
  77.  */
  78. long filesize(name)
  79. register char *name;
  80. {
  81.     extern struct stat statbuf;
  82.     
  83.     if(Fsfirst(name,(int)(0x01 | 0x020)) != 0)
  84.     {
  85.         return 0L;
  86.         
  87.     }
  88.  
  89.     return statbuf.st_size;
  90. }
  91.  
  92.  
  93. /*
  94.  * Write a string to console
  95.  */
  96. Bconws(s)
  97. register char *s;
  98. {
  99.     while(*s)
  100.         Bconout(2, *s++);
  101. }
  102.  
  103. #ifndef MWC
  104.  
  105. /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
  106. /*                                       */
  107. /*  ALCYON C dependant, this routine must return the base address of       */
  108. /*    of the linea variable block                       */
  109. /*                                       */
  110. /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
  111.  
  112. /*
  113.  * return the base address of the line A variables 
  114.  */
  115. int *aaddress()
  116. {
  117.     asm("dc.w $A000");    /* Line A trap - 0000 is init aline  */
  118.                 /* d0 and a0 now contain the address */
  119.                 /* so we can just return and the result
  120.                  * will be valid
  121.                  */
  122. }
  123.  
  124.  
  125. /*
  126.  *  Make hi rez screen bios handle 50 lines of 8x8 characters
  127.  *
  128.  * Adapted to C use from origonal asm posting
  129.  *
  130.  */
  131. hi50()
  132. {
  133.     /* Switch to 50 lines display */
  134.  
  135.     asm(".dc.w    $a000");        /* get the important pointers */
  136.  
  137.     asm("move.l  04(a1),a1");    /* a1 -> 8x8 font header */
  138.  
  139.     asm("move.l  72(a1),-$0A(a0)");    /* v_off_ad <- 8x8 offset table addr */
  140.     asm("move.l  76(a1),-$16(a0)");    /* v_fnt_ad <- 8x8 font data addr */
  141.  
  142.     asm("move.w  #008,-$2E(a0)");    /* v_cel_ht <- 8    8x8 cell height */
  143.     asm("move.w  #049,-$2A(a0)");    /* v_cel_my <- 49   maximum cell "Y" */
  144.     asm("move.w  #640,-$28(a0)"); /* v_cel_wr <- 640  offset to cell Y+1 */
  145.  
  146. }
  147.    
  148. /*
  149.  * Make hi rez screen bios handle 25 lines of 8x16 characters
  150.  *
  151.  */
  152. hi25()
  153. {
  154.     
  155.     /* Switch to 25 lines display */
  156.  
  157.  
  158.     asm(".dc.w    $a000");        /* get the important pointers */
  159.     
  160.     asm("move.l  08(a1),a1");    /* a1 -> 8x16 font header */
  161.  
  162.     asm("move.l  72(a1),-$0A(a0)");    /* v_off_ad <- 8x16 offset table addr */
  163.     asm("move.l  76(a1),-$16(a0)");    /* v_fnt_ad <- 8x16 font data addr */
  164.  
  165.     asm("move.w  #0016,-$2E(a0)");    /* v_cel_ht <- 16    8x16 cell height */
  166.     asm("move.w  #0024,-$2A(a0)");    /* v_cel_my <- 24    maximum cell "Y" */
  167.     asm("move.w  #1280,-$28(a0)");    /* v_cel_wr <- 1280  vertical byte offset */
  168. }
  169.  
  170. #else
  171.  
  172. /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
  173. /*                                       */
  174. /*     MWC  dependant, this routine must return the base address of       */
  175. /*    of the linea variable block                       */
  176. /*                                       */
  177. /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
  178. #include <linea.h>
  179. /*
  180.  * return the base address of the line A variables 
  181.  */
  182.  
  183. int *aaddress()
  184. {
  185.     linea0();    /* Init LineA - dumps returned values into la_init */
  186.     return (int *)(la_init.li_a0); /* Return address of Parameter Block */
  187. }
  188.  
  189.         /* Mark Williams C        */
  190.         /* See file hi5025.s       */
  191.         /* for functions hi50()    */
  192.         /* and hi25()           */
  193. #endif /* MWC */
  194.